import Mock from "mockjs"

let list:Array<any>=[
    {
        id:1,
        username:"小王",
        pwd:123
    },{
        id:2,
        username:"小花",
        pwd:123
    }
]

// let list=Mock.mock({
//     "list|10":[
//         {
//             "id":"@id",
//             "username":"@cname",
//             "pwd|1-10":1
//         }
//     ]
// })

Mock.mock("/login","post",(options:any)=>{
    // console.log(options.body);
    
   let {username,pwd}= JSON.parse(options.body)
//    console.log(username,pwd);
    let a= list.filter((item:any)=>{return item.username==username&&item.pwd==pwd})
//   console.log(a);
    if(a.length>0){
        return {
            code:0,
            mes:"登录成功",
            a
        }
    }else{
        return {
            code:2,
            mes:"登录失败"
        }
    }
   
})

let data={
    "code": 1,
    "msg": "获取列表数据成功",
    "statusMsg": "服务器成功返回请求的数据。",
    "status": 200,
    "data": {
        "lists": [
            {
                "select": [
                    {
                        "title": "选项一",
                        "size": 0
                    },
                    {
                        "title": "222",
                        "size": 1
                    },
                    {
                        "title": "3333",
                        "size": 1
                    },
                    {
                        "title": "444444",
                        "size": 0
                    }
                ],
                "info": null,
                "title": "18701553449",
                "id": "q2le0rk1y3",
                "endtime": "2020-02-01T06:40:00.000Z",
                "uid": "fimegt0j3b",
                "createVoteUserInfo": {
                    "phone": "18701553442",
                    "username": "yihang",
                    "id": "fimegt0j3b"
                },
                "size": 2,
                "selected": 1
            },
            {
                "select": [
                    {
                        "title": "米饭",
                        "size": 0
                    },
                    {
                        "title": "面",
                        "size": 1
                    },
                    {
                        "title": "粥",
                        "size": 1
                    },
                    {
                        "title": "馒头",
                        "size": 0
                    }
                ],
                "info": null,
                "title": "午饭吃啥？",
                "id": "a63suc8uh2",
                "endtime": "2020-02-01T06:40:00.000Z",
                "uid": "fimegt0j3b",
                "createVoteUserInfo": {
                    "phone": "18701553442",
                    "username": "yihang",
                    "id": "fimegt0j3b"
                },
                "size": 2,
                "selected": 1
            },
            {
                "select": [
                    {
                        "title": "米饭",
                        "size": 0
                    },
                    {
                        "title": "面",
                        "size": 0
                    },
                    {
                        "title": "粥",
                        "size": 0
                    },
                    {
                        "title": "馒头",
                        "size": 2
                    }
                ],
                "info": null,
                "title": "晚饭吃啥？",
                "id": "k80hykeqb",
                "endtime": "2020-02-01T06:40:00.000Z",
                "uid": "fimegt0j3b",
                "createVoteUserInfo": {
                    "phone": "18701553442",
                    "username": "yihang",
                    "id": "fimegt0j3b"
                },
                "size": 2,
                "selected": 3
            },
            {
                "select": [
                    {
                        "title": "米饭",
                        "size": 0
                    },
                    {
                        "title": "面",
                        "size": 1
                    },
                    {
                        "title": "粥",
                        "size": 0
                    },
                    {
                        "title": "馒头",
                        "size": 0
                    }
                ],
                "info": null,
                "title": "早餐吃啥？",
                "id": "15mprjd1hk",
                "endtime": "2020-02-01T06:40:00.000Z",
                "uid": "fimegt0j3b",
                "createVoteUserInfo": {
                    "phone": "18701553442",
                    "username": "yihang",
                    "id": "fimegt0j3b"
                },
                "size": 1,
                "selected": 1
            },
            {
                "select": [
                    {
                        "title": "逛街",
                        "size": 0
                    },
                    {
                        "title": "拥抱自然",
                        "size": 0
                    },
                    {
                        "title": "拥抱爱人",
                        "size": 0
                    },
                    {
                        "title": "111",
                        "size": 0
                    }
                ],
                "info": null,
                "title": "能出门你要干啥？",
                "id": "bw6m3n5a6n",
                "endtime": "2020-02-01T06:40:00.000Z",
                "uid": "fimegt0j3b",
                "createVoteUserInfo": {
                    "phone": "18701553442",
                    "username": "yihang",
                    "id": "fimegt0j3b"
                },
                "size": 0,
                "selected": null
            }
        ]
    }
}

Mock.mock("/list",()=>{
    return data
})